const { no, ok } = require('../../utils/utlis');

module.exports = {
	// 图片上传
	img: async (req, res, next) => {
		let { size, mimetype, filename } = req.file;

		let baseUrl = process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:3000/' : 'http:api.zylwin.cn/';
		const fullUrl = `${baseUrl}uploads/${filename}`;
		const url = `/uploads/${filename}`;
		res.send(
			ok({
				fullUrl,
				url,
				size,
				originalname: filename.substring(14, filename.length),
				type: mimetype
			})
		);
	}
};
